﻿using System;

namespace PlottingBasics.Axis
{
    /// <summary>
    /// A linear axis
    /// </summary>
    public class LinearAxis : AxisFunctorBase
    {
        public int Bins {get; private set;}
        public double LowEdge{get; private set;}
        public double HighEdge { get; private set; }

        public LinearAxis(int bins, double lowEdge, double highEdge)
            : base(bins)
        {
            this.Bins = bins;
            this.LowEdge = lowEdge;
            this.HighEdge = highEdge;
        }

        /// <summary>
        /// Returns a new func that will run our iterator
        /// </summary>
        /// <returns></returns>
        override protected Func<double> getIteratorFunc()
        {
            double delta = (HighEdge - LowEdge) / Bins;
            double start = LowEdge;

            return () =>
            {
                double old = start;
                start = start + delta;
                return old;
            };
        }

    }
}
